import { get,post } from "@/axios/api";
import useCounterStore from "@/store/user";

import router from "@/router";

const _store = useCounterStore()

//请求用户权限
async function getUserAuthority(id:any) {
   let userAuthority = null
   let params = {
    id,
     permission_tree:1
   }
   await get('/system/user/detail',params).then(res=>{
    
      if(res.status_code == 200){
        userAuthority = res.data
        localStorage.setItem('userType',userAuthority.user_type)
        //将权限信息保存在本地中
        sessionStorage.setItem('NavList',JSON.stringify(userAuthority.permissions))
      }
   })
   return userAuthority
}

  
function getOnePagePath() {
    let list = JSON.parse(sessionStorage.getItem('NavList'))
    list[0].children[0].fullPath = list[0].children[0].web_path 
    router.push(list[0].children[0].fullPath)
}






export default {
  getUserAuthority,
  getOnePagePath
}